package cn.com.homeyoda.aimate.aihealth.ui.kepu;

import android.content.Context;
import android.util.Log;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wzq.mvvmsmart.utils.GlideLoadUtils;

import java.util.List;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.MessageListBean;
import cn.com.homeyoda.aimate.aihealth.bean.PopularListBean;

/**
 * Created By 刘纯贵
 * Created Time 2020/4/30
 */
public class KePuListAdapter extends BaseQuickAdapter<PopularListBean.RowsBean, BaseViewHolder> {

    private Context mContext;
    public KePuListAdapter(int layoutResId, @Nullable List<PopularListBean.RowsBean> data, Context context) {
        super(layoutResId, data);
        mContext = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PopularListBean.RowsBean item) {

    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        Log.i("huage","KePuListAdapter=111=="+position);
        holder.setText(R.id.tv_title, getData().get(position).getTitle());
        ImageView imageView = holder.getView(R.id.iv_img);
        //holder.setImageResource(R.id.iv_img, R.mipmap.bg_kepu_normal);
        GlideLoadUtils.loadRoundCornerImg(imageView,getData().get(position).getCoverImage(),R.mipmap.ic_kepu1,5);
        holder.setText(R.id.tv_author, "发布人: " + getData().get(position).getReleasePeopleId());
        holder.setText(R.id.tv_read, getData().get(position).getBrowseCount() + "");
        String time = getData().get(position).getReleaseTime().split(" ")[0]; // 按空格分割，取第一部分
        holder.setText(R.id.tv_date, time);
    }



    @Override
    public void setNewData(@Nullable List<PopularListBean.RowsBean> data) {
        super.setNewData(data);
    }
}
